package com.pocket.cloud.order.service;

import com.pocket.cloud.order.dao.OrderMapper;
import com.pocket.cloud.order.entity.Order;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zhaozhile
 */
@Service
public class OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Transactional
    public boolean save(Order orderSettlement){
        int count = orderMapper.insert(orderSettlement);
        return count == 1;
    }

    public boolean delete(Long id){
        int count = orderMapper.deleteByPrimaryKey(id);
        return count == 1;
    }

    public boolean update(Order orderSettlement){
        int count = orderMapper.updateByPrimaryKeySelective(orderSettlement);
        return count == 1;
    }

    public Order getById(Long id){
        return orderMapper.selectByPrimaryKey(id).orElse(null);
    }

}
